package com.kiln.juxingqs.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import com.kiln.juxingqs.fragment.RechargeOneFragment

class RechargeRecordFragmentPageAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(
    fm,
    BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
) {
    val fragments: Array<Fragment?> by lazy {
        arrayOfNulls(1)
    }

    override fun getItem(position: Int): Fragment {
        if (position == 0 && fragments[0] == null) {
            fragments[0] = RechargeOneFragment()
        }
        return fragments[position]!!
    }

    override fun getCount(): Int {
        return fragments.size
    }

    override fun getPageTitle(position: Int): CharSequence? {
        var title = ""
//        if (position == 0 && fragments[0] == null) {
//            title = "余额"
//        } else

        if (position == 0 && fragments[0] == null) {
            title = "充值记录"
        }
        return title
    }
}